<?php

class  Zend_View_Helper_Login extends Zend_View_Helper_Abstract implements Zend_View_Helper_Interface {

	public $view;

	/**
	 * View Helper zur Verfügung stellen
	 * @param Zend_View_Interface $view
	 */
	public function setView(Zend_View_Interface $view) {
		$this->view = $view;
	}

	/**
	 * Login "box"
	 */
	public function  login($user) {
		if ($user != null) {
			$realName = $user->realName;
		} else {
			$realName = "";
		}
		$auth = Zend_Auth::getInstance();
		if ($auth->hasIdentity()) {
			$userId = $auth->getIdentity();
			$userId = $userId[1];

			echo ("<a href='" . $this->view->url(array('controller' => 'auth', 'action' => 'login', 'logout' => 'yes'), 'default', true) .
					"'>user logged in: " . $realName . " id:$userId<br/></a><br/>");
		} else {
			echo ("<a href='" . $this->view->url(array('controller' => 'auth', 'action' => 'login'), 'default', true) . "'>login</a><br/>");
		}

	}
}

